import React from 'react';
import { Alert as AntdAlert } from 'antd';
import type { AlertProps as AntdAlertProps } from 'antd';
import { createStyles } from 'antd-style';

export interface AlertProps extends AntdAlertProps {
  /**
   * @description 自定义样式类名
   */
  customClassName?: string;
}

const useStyles = createStyles(({ token, css }) => ({
  alert: css`
    border-radius: ${token.borderRadius}px;
  `,
}));

const AlertComponent: React.FC<AlertProps> = ({ customClassName, className, ...restProps }) => {
  const { styles, cx } = useStyles();
  
  const alertClassName = cx(
    className,
    customClassName,
    styles.alert
  );

  return <AntdAlert className={alertClassName} {...restProps} />;
};

const Alert = Object.assign(AlertComponent, {
  ErrorBoundary: AntdAlert.ErrorBoundary,
});

export { Alert };
export default Alert;

